package com.bkq.cb;

import java.util.Calendar;


import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;


public class DayModeScreen extends Activity {
	private Button back,ok;
	private EditText dayEd;
	String idUser,day,nameUser;
	public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
	     setContentView(R.layout.daymode);
	     back = (Button)findViewById(R.id.backIma_DayMode);
	     dayEd = (EditText)findViewById(R.id.dayTxt_DayMode);
	     ok = (Button)findViewById(R.id.okBnt_DayMode);
	     Bundle extras = getIntent().getExtras();

         if(extras!=null)
	     {
	    idUser = extras.getString("idUser").toString();
	    nameUser = extras.getString("nameUser").toString();
	     }
            back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
	       dayEd.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				 int y,m,d;
					Calendar c = Calendar.getInstance();        
		            y = c.get(Calendar.YEAR);        
		              m= c.get(Calendar.MONTH);        
		             d = c.get(Calendar.DAY_OF_MONTH); 
		             DatePickerDialog dp = new DatePickerDialog(DayModeScreen.this,new DatePickerDialog.OnDateSetListener() {
		            	  

						@Override
						public void onDateSet(DatePicker view, int year,
								int monthOfYear, int dayOfMonth) {
							// TODO Auto-generated method stub
							  String erg = "";
		                        erg = String.valueOf(dayOfMonth);                      
		                        erg += "/" + String.valueOf(monthOfYear+1);                    
		                        erg += "/" + year;  
		                      dayEd.setText(erg);
		                      day = erg;
						}
		            	   
		                 }, y, m, d);
		             
		              dp.setTitle("Choose day:");
		              dp.show();
			}
		});
	       ok.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					Intent i = new Intent(DayModeScreen.this,CashBookScreen.class);
						
					i.putExtra("day", day);
						i.putExtra("check", "1");
						i.putExtra("idUser", idUser);
						i.putExtra("nameUser", nameUser);
						i.putExtra("dayTo", "31/12/2011");
						startActivity(i);
				}
			});
	}
}
